home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / glimpsehttp / cgi-bin / mfs < prev    next >
Text File  |  1995-05-16  |  2KB  |  73 lines

  1. #!/usr/local/bin/perl
  2. #
  3. # 2/22/94    Version 1.0, shell script version    Paul Clark
  4. # 4/21/94    Version 1.1, multiple archives support    Paul Clark
  5. # 4/22/94    Version 1.2, perl script        Paul Clark
  6. # 8/05/94    Version 1.3, as aglimpse evolved    Paul Clark
  7. #10/05/94    Version 1.4, with secure aglimpse    Paul Clark
  8.  
  9. # **** **** **** ****    CONFIGURABLE VARIABLES     **** **** **** ****
  10. $HTTPD_HOME="/usr1/paul/httpd" ;
  11.  
  12. # **** **** **** **** NO CONFIGURATION NEEDED BELOW **** **** **** ****
  13.  
  14. $_ = $ENV{'PATH_INFO'};
  15. if ( m|^/([0-9]+)(.*)$| ) {
  16.     $script = $1;
  17.     $path = $2;
  18.     $path =~ s|"||g;
  19. } else {
  20.     print "Content-type: text/html\n\n";
  21.     print "<TITLE>Wrong file request $_</TITLE>\n";
  22.     print "<H1>Wrong file request $_</H1>\n";
  23.     print "Cannot determine numeric script ID from request $_\n";
  24.     exit;
  25. }
  26.  
  27. undef $indexdir;
  28. if (!open(AMGRCONF,"$HTTPD_HOME/wwwlib/amgr.cfg")) {
  29.     $code = "$!";
  30.     print "Content-type: text/html\n\n";
  31.     print "<TITLE>Cannot open configuration file</TITLE>\n";
  32.     print "<H1>Cannot open configuration file</H1>\n";
  33.     print "Cannot open configuration file\n";
  34.     print "$HTTPD_HOME/wwwlib/amgr.cfg : $code\n";
  35.     exit;
  36. }
  37. line: while (<AMGRCONF>) {
  38.     @_ = split(/\t/);
  39.     if ( $_[3] eq $script ) {
  40.         $indexdir=$_[0];
  41.         $urlpath = $_[1];
  42.         last line;
  43.     }
  44. }
  45. $urlpath = "/$urlpath" if $urlpath !~ /^\//;
  46. close(AMGRCONF);
  47. if (!$indexdir) {
  48.     print "Content-type: text/html\n\n";
  49.     print "<TITLE>Script '$script' not found</TITLE>\n";
  50.     print "<H1>Script '$script' not found</H1>\n";
  51.     print "Cannot find script '$script' in the configuration file\n";
  52.     print "$HTTPD_HOME/wwwlib/amgr.cfg.\n";
  53.     exit;
  54. }
  55.  
  56. $path = $indexdir . $path;
  57.  
  58. if (-d $path) {
  59.     print "Location: $urlpath\n\n";
  60.     exit;
  61. }
  62.  
  63. $ENV{'PATH_INFO'} = $path;
  64.  
  65. if (!exec("$HTTPD_HOME/wwwlib/getfile $indexdir")) {
  66.     $code = "$!";
  67.     print "Content-type: text/html\n\n";
  68.     print "<TITLE>Cannot execute getfile</TITLE>\n";
  69.     print "<H1>Cannot execute getfile</H1>\n";
  70.     print "Cannot execute $HTTPD_HOME/wwwlib/getfile : $code\n";
  71.     exit;
  72. }
  73.